home *** CD-ROM | disk | FTP | other *** search
/ Robotics & Artificial Int…3 (Professional Edition) / Robotics & Artificial Intelligence Tools 2003 (Professional Edition).iso / neural network tool and application / nsinstall.exe / data1.cab / DllSys_Files / FuzAxon / BKBellFu.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-08  |  2.1 KB  |  68 lines

  1. // Dynamic link library implementation of NeuroSolutions BackAxon component
  2.  
  3. #include "NSDLL.h"
  4.  
  5. /* Backpropagation of component */
  6.  
  7. __declspec(dllexport) void performBackFuzzyAxon(
  8.     DLLData    *instance,    // Pointer to instance data (may be NULL)
  9.     DLLData    *dualInstance,    // Pointer to forward axonÆs instance data (may be NULL)
  10.     NSFloat    *data,         // Pointer to the layer of processing elements (PEs)
  11.     int     rows,        // Number of rows of PEs in the layer
  12.     int     cols,        // Number of columns of PEs in the layer
  13.     NSFloat    *error,        // Pointer to the sensitivity vector
  14.     NSFloat    *param,     // Pointer to the layer of parameters for the MFs
  15.     int        paramIndex,    // Index of the MF parameter
  16.     int        winnerIndex,// Index of the winning MF
  17.     NSFloat winnerVal,    // Value of the winning Input
  18.     NSFloat *returnVal    // Return value
  19.     )
  20. {
  21.     NSFloat b;
  22.     NSFloat c;
  23.     NSFloat tmp1;
  24.     NSFloat tmp2;
  25.     NSFloat denom;
  26.     NSFloat a = *(param + winnerIndex);
  27.     if (a == 0.0f)
  28.         *returnVal = 0.0f;
  29.     b = *(param + winnerIndex + 1);
  30.     c = *(param + winnerIndex + 2);
  31.     tmp1 = (winnerVal - c)/a;
  32.     tmp2 = tmp1 == 0 ? 0 : (NSFloat)pow(tmp1*tmp1, b);
  33.     denom = (1 + tmp2)*(1 + tmp2);
  34.     if (paramIndex == winnerIndex)
  35.         *returnVal = (2*b*tmp2/(a*denom));
  36.     if (paramIndex == (winnerIndex + 1)) {
  37.         if (tmp1 == 0)
  38.             *returnVal = 0.0f;
  39.         else
  40.             *returnVal = ((NSFloat)-log(tmp1*tmp1)*tmp2/denom);
  41.     }
  42.     if (paramIndex == (winnerIndex + 2)) {
  43.         if (winnerVal == c)
  44.             *returnVal = 0.0f;
  45.         else
  46.             *returnVal = (2*b*tmp2/((winnerVal - c)*(denom)));
  47.     }
  48. }
  49.  
  50. /******************************************/
  51. /* Management of instance data (OPTIONAL) */
  52. /*
  53. __declspec(dllexport) DLLData *allocBackFuzzyAxon(
  54.     DLLData    *oldInstance,    // Pointer to the last instance if reallocating
  55.     DLLData    *dualInstance,    // Pointer to forward axonÆs instance data (may be NULL)
  56.     int     rows,        // Number of rows of PEs in the layer
  57.     int     cols        // Number of columns of PEs in the layer
  58.     )
  59. {
  60.     DLLData *instance = allocDLLInstance(oldInstance);
  61.     return instance;
  62. }
  63.  
  64. __declspec(dllexport) void freeBackFuzzyAxon(DLLData *instance)
  65. {
  66.     freeDLLInstance(instance);
  67. }
  68. */